package com.zj.leetcode.easy.numAndBit;

/**
 * @program: algorithm
 * @description: 2 的幂
 * 231 power-of-two
 * @author: Zhang Bo
 * @create: 2022-01-14 17:05
 **/
public class PowerOfTwo {
    public static void main(String[] args) {
        int n = -2147483648;
        Solution solution = new PowerOfTwo().new Solution();
        System.out.println(solution.isPowerOfTwo(n));
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean isPowerOfTwo(int n) {
            if(n == 0 || n == Integer.MIN_VALUE){
                return false;
            }
            int sub = n - 1;
            return (n & sub) == 0;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
